package com.eco.fanliapp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.dao.BeginnerModeMapper;
import com.eco.fanliapp.entity.BeginnerMode;
import com.eco.fanliapp.service.IBeginnerModeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BeginnerModeServiceImpl extends ServiceImpl<BeginnerModeMapper, BeginnerMode> implements IBeginnerModeService {

    @Autowired
    private BeginnerModeMapper beginnerModeMapper ;

    /**
     *  根据奖励代号来更新符合条件的数据库记录,app_beginner_mode
     *
     * @param record
     */
    @Override
    public ServerResponse updateByRewardTypeCode(BeginnerMode record) {
        int update = beginnerModeMapper.updateByRewardTypeCode(record);
        if (update == 1){
            return ServerResponse.createBySuccessMessage("修改成功");
        }
        return ServerResponse.createByErrorMessage("修改不成功");
    }


    /**
     *  根据奖励代号获取一条数据库记录,app_beginner_mode
     *
     * @param rewardTypeCode
     */
    @Override
    public ServerResponse<BeginnerMode> selectByRewardTypeCode(Integer rewardTypeCode) {
        BeginnerMode beginnerMode = beginnerModeMapper.selectByRewardTypeCode(rewardTypeCode);
        if (beginnerMode !=null){

            return ServerResponse.createBySuccess("查询成功",beginnerMode);
        }
        return ServerResponse.createBySuccess("查询失败",null);
    }
}
